/**
 * Lab05A.cpp
 *    Basic Recursion - Sum from 1 to N and factorial
 *
 *  Created on: Feb 27, 2014
 *      Author: Anthony Varghese
 */

/**
 * Recursive add function
 * computes 1 + 2 + 3 + ... + (N-1) + N
 * precondition: n >= 0
 * postcondition: None
 */
int add(int n){
	if (n==0) return 0;
	return n + add(n-1);
}

/**
 * Recursive factorial function
 * computes 1 * 2 * 3 * ... * (N-1) * N
 * precondition: n >= 0
 * postcondition: None
 */
int factorial(int n){

   return 1;
}

#include <iostream>

int main(){
	const int N = 10;
	std::cout << "Sum of numbers from 1 to " << N << " is: " << add( N ) << std::endl << std::endl;
	std::cout << N << " factorial is:                " << factorial( N ) << std::endl;
}


